package individual;

import java.awt.Color;
import java.awt.Dimension;
import java.util.ArrayList;
import java.util.List;

import behavior.Behavior;
import behavior.BoidBehavior;
import behavior.Parameters;

import debugger.Debugger;

import effects.Sound;

import Environment.*;


import utilities.*;

/**
 * Creates a Prey which is attracted to Protector and repulsive from a Predator. 
 *  
 *  @author Ga-Young Joung and Perry Zheng
 */
public class Prey extends Boid{

	static Behavior myBehavior;
	
	/**
	 * Constructs a Prey
	 * @param center the center of the Prey boid
	 * @param size the size
	 * @param velocity the initial velocity of the boid
	 * @param environment the environment it is in
	 * @param parameters the parameter (i.e radius of neighbors)
	 * @param debugger debugger
	 */
	public Prey(Vector center, Dimension size, Vector velocity, Environment environment, Parameters parameters, Debugger debugger) {
		super(center, size, velocity, environment, parameters, debugger);
		myColor = Color.blue;
		myBehavior = new BoidBehavior("Protector", 60, "Predator", 50, myParameters, true);
	}

	
	/**
	 * Calls the myBehavior's getNextVelocity() method to update
	 * the current Prey given its surrounding moving entities. 
	 */
    public void update (List<MovingEntity> allIndividuals) {
    	myNextVelocity = myBehavior.getNextVelocity(this, allIndividuals);
    	ArrayList<Vector> ret = myEnvironment.getBoundary().getNewPositionAndVelocity(myCenter, myNextVelocity, mySize);
    	myNextVelocity = ret.get(0);
    	myNextCenter = ret.get(1);
    	
        myTrail.add(new Vector(myNextCenter));
        if (myTrail.size() >= myDebugger.myMaxTrail)
        {
            myTrail.remove(0);
        }
    }
}
